<template>
    <div class="login_container">
    <el-form ref="testRef" :model="test1" class="login-box">
      <h3 style="text-align: center">TEST</h3>
      <el-form-item label="f_code">
        <el-input
          type="test"
          placeholder="请输入"
          v-model="test1.f_code"
        ></el-input>
      </el-form-item>
      <el-form-item label="f_name">
        <el-input
          type="test"
          placeholder="请输入"
          v-model="test1.f_name"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit1()">添加</el-button>
        <el-button type="primary" @click="submit2()">删除</el-button>
        <el-button type="primary" @click="submit3()">更新</el-button>
        <el-button type="primary" @click="submit4()">查询</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
    name: "test1",
    data(){
        return{
            test1:{
                f_code: '',
                f_name: '',
            },
        }
    },
    methods:{
        submit1() {
        this.$refs.testRef.validate(async valid => {
        if (!valid)return
          const {data:res} = await this.$http.post("Data/apis/factoryadd",this.test1);
          if(res.code == 200){
              alert("操作成功")
          }
        }
        )
        },
        submit2(){
          this.$refs.testRef.validate(async valid => {
        if (!valid)return
          const {data:res} = await this.$http.post("Data/apis/factorydel",this.test1);
          if(res.code == 200){
              alert("操作成功")
          }
        }
        )
        },
        submit3(){
          this.$refs.testRef.validate(async valid => {
        if (!valid)return
          const {data:res} = await this.$http.post("Data/apis/factoryput",this.test1);
          if(res.code == 200){
              alert("操作成功")
          }
        }
        )
        },
        submit4(){
          this.$refs.testRef.validate(async valid => {
        if (!valid)return
          const {data:res} = await this.$http.post("Data/apis/o_messageget",this.test1);
          if(res.code == 200){
              alert("操作成功")
          }
        }
        )
        },
    }
    
}
</script>

<style>
.login-box {
  width: 350pt;
  margin: 150px auto;
  border: 1px solid #dcdfe6;
  padding: 20px;
  border-radius: 5px;
  box-shadow: 0 0 30px #dcdfe6;
}
</style>